import { _orderDetail } from "../../../service/api";
import formatDate from "../../../utils/format";

Page({
  data: {
    orderId: 0,
    orderInfo: {},
    goodsList: [],
  },
  onLoad: function (options) {
    this.setData({ orderId: options.id });
    this.initData();
  },
  async initData() {
    const res = await _orderDetail({ orderId: this.data.orderId });
    const date = new Date(res.orderInfo.add_time * 1000);
    res.orderInfo.add_time = formatDate(date, "yyyy-MM-dd");
    this.setData({ orderInfo: res.orderInfo, goodsList: res.orderGoods });
  },
});
